package com.payment.web.controller.app;

import com.payment.common.base.AjaxResult;
import com.payment.system.service.IAbroadExchangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;

/**
 * @author fuzhili
 * @Description: 境外消费
 * @date 2019/11/23 9:21
 */
@Controller
@RequestMapping("/app/abroadExchange")
public class AbroadExchangeController {
	@Autowired
	private IAbroadExchangeService abroadExchangeService;

	/**
	 * 获取汇率列表
	 *
	 * @return
	 */
	@RequestMapping("/rateList")
	@ResponseBody
	public AjaxResult rateList() {
		return abroadExchangeService.selectRateList();
	}

	/**
	 * 获取商品列表
	 *
	 * @param currercyCode
	 *            币种
	 * @param cnyAmount
	 *            汇率
	 * @return
	 */
	@PostMapping("/goodsList")
	@ResponseBody
	public AjaxResult goodsList(String currercyCode, BigDecimal cnyAmount) {
		return abroadExchangeService.selectGoodsList(currercyCode, cnyAmount);
	}

	/**
	 * 境外下单
	 *
	 * @param merId
	 *            用户id
	 * @param currercyCode
	 *            币种
	 * @param orderAmount
	 *            订单金额
	 * @param number
	 *            交易数量
	 * @param exchangeRate
	 *            交易汇率
	 * @param foreignAmt
	 *            外币金额
	 * @param goodsNo
	 *            订单编号
	 * @param bankCardNo
	 * 	                                卡号           
	 * @return
	 */
	@PostMapping("/placeOrder")
	@ResponseBody
	public AjaxResult placeOrder(String merId, String ip, String currercyCode, BigDecimal orderAmount, Integer number,
			BigDecimal exchangeRate, BigDecimal foreignAmt, String goodsNo,String bankCardNo) {
		return abroadExchangeService.placeOrder(merId, ip, currercyCode, orderAmount, number, exchangeRate, foreignAmt,
				goodsNo,bankCardNo);
	}
}
